'use strict';

var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var fs = require("fs");
var request = require('request');
var countProgress = 0;
var port = 9093;

app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());

app.use(express.static(__dirname + '/public'));


app.post('/api/login', function (req, res) {
  fs.readFile("./test_json/login_token.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:login_token.json");
  });
});

app.get('/api/providers/sessioninfo', function (req, res) {
  fs.readFile("./test_json/sessioninfo.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:sessioninfo.json");
  });
});

app.get('/api/providers/logoninfo', function (req, res) {
  fs.readFile("./test_json/logoninfo.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:logoninfo.json");
  });
});

app.get('/api/providers/imm_active_events', function (req, res) {
  fs.readFile("./test_json/imm_active_events.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_active_events.json");
  });
  // var arr = [];
  //  for(var i=0; i<1000; i++){
  //      var obj = {
  //          "action": 2,
  //          "audit": 1,
  //          "cmnid": "",
  //          "date": "2017-01-09T17:05:57.110",
  //          "description": 2,
  //          "eventid": "0x4000002000000000",
  //          "index": i,
  //          "logsequence": 5597,
  //          "message": i,
  //          "message_more": "",
  //          "sequence": 5869,
  //          "service_state": 4,
  //          "severity": "I",
  //          "source": "System"
  //      }
  //      arr[i] = obj;
  //  }
});

app.get('/api/providers/imm_fod_tier', function (req, res) {
  fs.readFile("./test_json/imm_fod_tier.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_fod_tier.json");
  })
});

app.get('/api/providers/fp_usb_port', function (req, res) {
  fs.readFile("./test_json/fp_usb_port.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:fp_usb_port.json");
  })
});

app.get('/api/dataset/imm_status_power', function (req, res) {
  fs.readFile("./test_json/imm_status_power.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_status_power.json");
  })
});

app.get('/api/providers/locationled', function (req, res) {
  fs.readFile("./test_json/locationled.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:locationled.json");
  });
});

app.get('/api/dataset/imm_props_environ', function (req, res) {
  fs.readFile("./test_json/imm_props_environ.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_props_environ.json");
  });
});

app.get('/api/dataset/fan-list', function (req, res) {
  fs.readFile("./test_json/fan-list.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:fan-list.json");
  });
});

app.get('/api/dataset/imm_properties', function (req, res) {
  fs.readFile("./test_json/imm_properties.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_properties.json");
  });
});

app.get('/api/providers/xccenvinfo', function (req, res) {
  fs.readFile("./test_json/xccenvinfo.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:xccenvinfo.json");
  });
});

app.get('/api/dataset/sys_info', function (req, res) {
  fs.readFile("./test_json/sys_info.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:sys_info.json");
  });
});

app.get('/api/dataset/sys_inventory', function (req, res) {

  if(req.query.params == "Sys_GetInvGeneral")
  {
    fs.readFile("./test_json/Sys_GetInvGeneral.json", function (error, fileData) {
      if (error) {
        console.log('read err : ' + error);
      }
      res.json(JSON.parse(fileData));
      console.log("send:Sys_GetInvGeneral.json");
    });
  }
  else
  {
    fs.readFile("./test_json/sys_inventory.json", function (error, fileData) {
      if (error) {
        console.log('read err : ' + error);
      }
      res.json(JSON.parse(fileData));
      console.log("send:sys_inventory.json");
    });
  }
});

app.get('/api/dataset/pwrmgmt', function (req, res) {

  if(req.query.params == "GetPowerRealtimeData")
  {
    fs.readFile("./test_json/GetPowerRealtimeData.json", function (error, fileData) {
      if (error) {
        console.log('read err : ' + error);
      }
      res.json(JSON.parse(fileData));
      console.log("send:GetPowerRealtimeData.json");
    });
  }
  if(req.query.params == "GetThermalRealTimeData")
  {
    fs.readFile("./test_json/GetThermalRealTimeData.json", function (error, fileData) {
      if (error) {
        console.log('read err : ' + error);
      }
      res.json(JSON.parse(fileData));
      console.log("send:GetThermalRealTimeData.json");
    });
  }
  if(req.query.params == "GetPowerPolicySettings")
  {
    fs.readFile("./test_json/GetPowerPolicySettings.json", function (error, fileData) {
      if (error) {
        console.log('read err : ' + error);
      }
      res.json(JSON.parse(fileData));
      console.log("send:GetPowerPolicySettings.json");
    });
  }
  if(req.query.params == "GetPowerInfoForRedunMode")
  {
    fs.readFile("./test_json/GetPowerInfoForRedunMode.json", function (error, fileData) {
      if (error) {
        console.log('read err : ' + error);
      }
      res.json(JSON.parse(fileData));
      console.log("send:GetPowerInfoForRedunMode.json");
    });
  }

});

app.get('/api/dataset/imm_power_supplies', function (req, res) {
  fs.readFile("./test_json/imm_power_supplies.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_power_supplies.json");
  });
});

app.post('/api/providers/poweraction', function (req, res) {
  console.log('recv post.data:', req.body);
  fs.readFile("./test_json/poweraction.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:poweraction.json");
  });
});


app.get('/api/providers/imm_os_failures', function (req, res) {
  fs.readFile("./test_json/imm_os_failures.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_os_failures.json");
  });
});

app.get('/api/providers/rp_screenshot', function (req, res) {
  fs.readFile("./test_json/rp_screenshot.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_screenshot.json");
  });
});

app.post('/api/providers/rp_screenshot_config', function (req, res) {
  fs.readFile("./test_json/rp_screenshot_config.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_screenshot_config.json");
  });
});

app.post('/api/providers/imm_reset', function (req, res) {
  fs.readFile("./test_json/imm_reset.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_reset.json");
  });
});

app.post('/api/providers/rp_bootvideo', function (req, res) {
  fs.readFile("./test_json/rp_bootvideo_config.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_bootvideo_config.json");
  });
});

app.get('/api/providers/rp_bootvideo', function (req, res) {
  fs.readFile("./test_json/rp_bootvideo_list.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_bootvideo_list.json");
  });
});

app.get('/api/providers/rp_kvm_num', function (req, res) {
  fs.readFile("./test_json/rp_kvm_num.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_kvm_num.json");
  });
});

app.post('/api/dataset', function (req, res) {
  fs.readFile("./test_json/dataset.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:dataset.json");
  });
});

app.get('/api/dataset/imm_power', function (req, res) {
  fs.readFile("./test_json/imm_power.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_power.json");
  });
});

app.get('/api/providers/rp_kvm_list', function (req, res) {
  fs.readFile("./test_json/rp_kvm_list.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_kvm_list.json");
  });
});

app.post('/api/providers/rp_cred', function (req, res) {
  fs.readFile("./test_json/rp_cred.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_cred.json");
  });
});

app.post('/api/providers/rp_kvm_reqpreempt', function (req, res) {
  fs.readFile("./test_json/rp_kvm_reqpreempt.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_kvm_reqpreempt.json");
  });
});

app.post('/api/providers/rp_kvm_preemptstatus', function (req, res) {
  fs.readFile("./test_json/rp_kvm_preemptstatus.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_kvm_preemptstatus.json");
  });
});

app.get('/api/providers/logout', function (req, res) {
  fs.readFile("./test_json/logout.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:logout.json");
  });
});

app.post('/api/function', function (req, res) {
  fs.readFile("./test_json/function.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:function.json");
  });
});

app.get('/api/dataset/imm_ports', function (req, res) {
  fs.readFile("./test_json/imm_ports.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_ports.json");
  });
});
app.get('/api/providers/port_state', function (req, res) {
  fs.readFile("./test_json/port_state.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
  });
});


app.get('/download/HostScreenShot.png',function(req,res,next){

  res.download("./download/HostScreenShot.png");
});

app.get('/download/Mini_ScreenShot.png',function(req,res,next){

  res.download("./download/miniscreen.png");
});

app.get('/download/export.xlsx',function(req,res,next){

  res.download("./download/export.xlsx");
});


app.post('/api/providers/imm_export', function (req, res) {
  fs.readFile("./test_json/imm_export.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_export.json");
  });
});

app.get('/api/dataset/imm_users_global', function (req, res) {
  fs.readFile("./test_json/imm_users_global.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_users_global.json");
  });
});

app.get('/api/dataset/imm_users', function (req, res) {
  fs.readFile("./test_json/imm_users.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_users.json");
  });
});

app.get('/api/providers/trespass', function (req, res) {
  fs.readFile("./test_json/trespass.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:trespass.json");
  });
});

app.get('/api/providers/rp_session', function (req, res) {
  fs.readFile("./test_json/rp_session_get.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_session_get.json");
  });
});

app.post('/api/providers/rp_session', function (req, res) {
  fs.readFile("./test_json/rp_session_post.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_session_post.json");
  });
});

app.get('/api/providers/rp_servermacro', function (req, res) {
  fs.readFile("./test_json/rp_servermacro_get.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_servermacro_get.json");
  });
});

app.post('/api/providers/rp_servermacro', function (req, res) {
  fs.readFile("./test_json/rp_servermacro_post.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:rp_servermacro_post.json");
  });
});

app.get('/api/dataset/imm_ethernet', function (req, res) {
  fs.readFile("./test_json/imm_ethernet.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:imm_ethernet.json");
  });
});

app.get('/api/providers/power_restore_policy', function (req, res) {
  fs.readFile("./test_json/power_restore_policy_get.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:power_restore_policy_get.json");
  });
});

app.post('/api/providers/power_restore_policy', function (req, res) {
  fs.readFile("./test_json/power_restore_policy_set.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:power_restore_policy_set.json");
  });
});

app.get('/api/providers/heartbeats', function (req, res) {
  fs.readFile("./test_json/heartbeats.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:heartbeats.json");
  });
});

app.get('/api/dataset/imm_event_recipients_global', function(req, res){
  res.json({
    "items": [
      {
        "delay_between_attempts": 30,
        "delay_between_entries": 30,
        "retry_limit": 5
      }
    ]

  });
});
app.get('/api/dataset/imm_event_recipients', function (req, res) {
  fs.readFile("./test_json/imm_event_recipients.json", function(error, fileData){
    if(error){
      console.log("read err :"+ error);
    }else{
      res.json(JSON.parse(fileData));
    }
  });
});
app.get('/api/dataset/imm_smtp', function(req, res) {
  res.json({
    "items": [
      {
        "smtp_auth": 1,
        "smtp_authmethod": 1,
        "smtp_email": "test@lenovo.com",
        "smtp_host": "10.20.0.1",
        "smtp_password": "*",
        "smtp_port": 25,
        "smtp_username": "TEST"
      }
    ]

  });
});
app.get('/api/dataset/imm_snmp', function(req, res){
  fs.readFile("./test_json/imm_snmp.json", function(error, fileData){
    if(error){
      console.log("read err :"+ error);
    }else{
      res.json(JSON.parse(fileData));
    }
  });
});
app.get('/api/providers/imm_maintenance_log', function(req, res){
  fs.readFile("./test_json/imm_maintain_history.json", function(error, fileData){
    if(error){
      console.log("read err :"+ error);
    }else{
      res.json(JSON.parse(fileData));
    }
  });
});
app.post('/api/providers/imm_event_log', function (req, res) {
  // fs.readFile("./test_json/imm_event_log.json", function(error, fileData){
  // 	if(error){
  // 		console.log("read err :"+ error);
  // 	}else{
  // 		res.json(JSON.parse(fileData));
  // 	}
  // });
  console.log("get event request");
  var arr = [];
  var i = 0;
  var severity = "I";
  var date = "2016-10-08T15:06:02.280";
  while(i<199){
    if(i<100){
      severity = "E";
      date = "2016-10-07T00:06:02.280";
    }else{
      severity = "I";
      date = "2016-10-08T00:06:02.280";
    }
    var obj = {
      "action": 2,
      "audit": 1,
      "cmnid": "0x4000002000000000" + i,
      "date": date,
      "description": 2,
      "eventid": "0x4000002000000000",
      "index": i,
      "logsequence": 5597,
      "message": "Management Controller SN# Serial:--- Reset was caused by restoring default values.Management Controller SN# Serial:--- Reset was caused by restoring default values.Management Controller SN# Serial:--- Reset was caused by restoring default values.Management Controller SN# Serial:--- Reset was caused by restoring default values.Management Controller SN# Serial:--- Reset was caused by restoring default values.",
      "message_more": "",
      "sequence": 5869 + i,
      "service_state": 4,
      "severity": severity,
      "source": "System"
    };
    arr[i] = obj;
    i++;
  }
  console.log("conplete create event log");
  var jdata = {
    "items": arr
  }
  res.json(jdata);
});
app.get('/api/providers/iteprovisioning', function (req, res) {
  fs.readFile("./test_json/iteprovisioning.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:iteprovisioning.json");
  });
});
app.get('/api/providers/fp_usb_port_cfg', function(req, res){
  res.json({
    "config_disabled": 0,
    "enableIDButton": 0,
    "hysteresis": 0,
    "owner": 0,
    "return": 0,
    "timeout": 0
  });
});
app.post('/api/providers/fp_usb_port_cfg', function(req, res){
  res.json({
    "return" : 0
  });
});
app.post('/api/providers/port_state', function(req, res){
  res.json({
    "return" : 1
  });
});
app.post('/api/providers/recipient_snmptrap_category', function(req, res){
  res.json({
    "return" : 0
  });
});
app.get('/api/function/net_access_control', function(req, res){
  res.json({
    "items": [
      {
        "begin_time": "2017-06-28T00:00",
        "datetime_current": "2017-06-13 10:14:51+00:00",
        "end_time": "2017-06-30T00:00",
        "interval_enabled": 1,
        "interval_time": "01:10,01:30,10:15,11:30",
        "ip_address": "192.168.1.2",
        "ip_enabled": 1,
        "ipv6_address": "2001:db8::1,2002::/16",
        "ipv6_enabled": 1,
        "mac_address": "aa:bb:cc:dd:ee:ff",
        "mac_enabled": 1,
        "time_enabled": 1
      }
    ]
  });
});
app.get('/api/dataset/imm_ddns', function(req, res){
  res.json({
    "items": [
      {
        "ddns_custom_name": "",
        "ddns_enabled": 1,
        "ddns_mode": 1,
        "ipv4_domain_name": "",
        "ipv6_domain_name": ""
      }
    ]

  });
});
app.get('/api/providers/fp_usb_port_en', function(req, res){
  res.json({
    "enabled": 1,
    "return": 0
  });
});
app.post('/api/providers/fp_usb_port_en', function(req, res){
  res.json({
    "return" : 1
  });
});

//firmware update start
app.post('/api/providers/fwupdate', function(req, res){
  var body = req.body;
  var param = "";
  for(var key in body){
    param = key;
    break;
  };
  console.log(param);
  if(param = "UPD_WebReserve"){
    res.json({
      "return" : 0
    });
  }else{

  }

});


app.get('/upload/progress', function(req, res){
  res.json({ "state" : "done" });
});

app.get('/api/dataset/imm_firmware_success', function(req, res){
  res.json({
    "items": [
      {
        "backup_build_id": "",
        "current_build_id": "",
        "filename": "/pstorage/flash/web.temp_upd",
        "firmware_type": "PSU",
        "pending_build_id": "PST301A",
        "primary_build_id": "",
        // "webfile_build_id": "psu_PST301A_156_2.upd",
        "webfile_build_id": "psu_PSI331_156_2_1.1.1_ACBE_1100KW_[1].upd"
      }
    ]
  });
});


app.get('/api/function/psu_update', function(req, res){
  res.json({
      "items": [
        {
          "fw_date": "2017-12-22",
          "input_state": 1,
          "mfg": "mfg",
          "model": "psu",
          "slot": "1",
          "version": "1.0"
        },
        {
          "fw_date": "2017-12-22",
          "input_state": 1,
          "mfg": "mfg",
          "model": "psu",
          "slot": "2",
          "version": "1.0"
        },
        {
          "fw_date": "2017-12-22",
          "input_state": 1,
          "mfg": "mfg",
          "model": "psu",
          "slot": "3",
          "version": "1.0"
        }
      ]
    }
  );
});

app.get('/api/dataset/imm_firmware_progress', function(req, res){
  countProgress++;
  res.json({
      "items": [
        {
          "action_percent_complete": 100,
          "action_state": "Complete OK",
          "action_status": 0,
          "error_detail": ""
        }
      ]
    }

  );
});

app.get('/api/providers/bootmode', function (req, res) {
  fs.readFile("./test_json/bootmode.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:bootmode.json");
  });
});
app.get('/api/providers/get_boot_order', function (req, res) {
  fs.readFile("./test_json/get_boot_order.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:get_boot_order.json");
  });
});
app.get('/api/providers/get_one_time_boot', function (req, res) {
  fs.readFile("./test_json/get_one_time_boot.json", function (error, fileData) {
    if (error) {
      console.log('read err : ' + error);
    }
    res.json(JSON.parse(fileData));
    console.log("send:get_one_time_boot.json");
  });
});

app.get('/api/test/getData', function(req, res){
  setTimeout(function () {
    res.json({
        "items": [
          {
            "name": "zhangzy30"
          }
        ]
      }

    );
  },5000)
});

app.get('/api/function/adapter_update', function(req, res){
  console.log(req.query);
  var params = req.query.params;
  if(params === "pci_GetAdapterListAndFW") {
    res.json({
      "items": [
        {
          "key": 1,
          "slotNo":1,
          "adapterName": "XXX",
          "location":8,
          "oobUpdFlag":1,
          "softwareID":"YYYY",
          "fw_version":"ZZZZ",
          "fw_status":2,
          "fw_manufacturer": "MMM",
          "fw_date": "NNNN" },
        {
          "key": 1,
          "slotNo":3,
          "adapterName": "XXX",
          "location":8,
          "oobUpdFlag":1,
          "softwareID":"YYYY",
          "fw_version":"ZZZZ",
          "fw_status":2,
          "fw_manufacturer": "MMM",
          "fw_date": "NNNN" },
        {
          "key": 1,
          "slotNo":2,
          "adapterName": "XXX",
          "location":8,
          "oobUpdFlag":1,
          "softwareID":"YYYY",
          "fw_version":"ZZZZ",
          "fw_status":2,
          "fw_manufacturer": "MMM",
          "fw_date": "NNNN" },
      ]

    })
  }
});

app.get('/api/dataset/imm_usb', function(req, res){
  res.json({
      "items": [
        {
          "imm_services_disabled": "0",
          "lan_over_usb_addr_mode": 0,
          "lan_over_usb_enabled": 0,
          "lan_over_usb_ipv4_address": "192.168.0.118",
          "lan_over_usb_ipv4_subnet_marks": "255.255.255.0",
          "lan_over_usb_ipv6_address": "fe80::020a:e4ff:fe1d:2c04",
          "os_lan_over_usb_ipv4_address": "192.168.0.120",
          "usb_eth_over_usb_enabled": 1,
          "usb_eth_to_eth_enabled": 1,
          "usb_mapped_ports": [
            {
              "eth_port": 3389,
              "ext_port": 3389,
              "id": 1
            },
            {
              "eth_port": 5900,
              "ext_port": 5900,
              "id": 2
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 3
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 4
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 5
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 6
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 7
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 8
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 9
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 10
            },
            {
              "eth_port": 0,
              "ext_port": 0,
              "id": 11
            }
          ]
        }
      ]
    }
  );
});

app.listen(port, function() {
  console.log("server start at: http://localhost:"+port);
});


